package cn.onepiece.smili.render.info;

import com.google.common.base.CaseFormat;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * PS：只支持单一主键，建议用过 id Long
 * 
 * @Author: haoting.wang
 * @Date: Created in 下午6:48 2017/5/25
 */
public class TableInfo {

    private String           basePackage;

    private String           tableName;

    private String           className;

    private String           lowerClassName;

    private String           pkName;

    private String           upperPkName;

    private String           pkType;

    private Set<String>      importList     = new HashSet<>();

    private List<ColumnInfo> columnInfoList = new ArrayList<>();

    public String getBasePackage() {
        return basePackage;
    }

    public void setBasePackage(String basePackage) {
        this.basePackage = basePackage;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getLowerClassName() {
        return lowerClassName;
    }

    public void setLowerClassName(String lowerClassName) {
        this.lowerClassName = lowerClassName;
    }

    public List<ColumnInfo> getColumnInfoList() {
        return columnInfoList;
    }

    public void setColumnInfoList(List<ColumnInfo> columnInfoList) {
        this.columnInfoList = columnInfoList;
    }

    public Set<String> getImportList() {
        return importList;
    }

    public void setImportList(Set<String> importList) {
        this.importList = importList;
    }

    public String getPkName() {
        return pkName;
    }

    public void setPkName(String pkName) {
        this.pkName = pkName;
    }

    public String getUpperPkName() {
        return upperPkName;
    }

    public void setUpperPkName(String upperPkName) {
        this.upperPkName = upperPkName;
    }

    public String getPkType() {
        return pkType;
    }

    public void setPkType(String pkType) {
        this.pkType = pkType;
    }

    public static class ColumnInfo {

        private String originName;

        private String jdbcType;

        private String remark;

        private String lowerCamelName;

        private String upperCamelName;

        private String javaType;

        public String getOriginName() {
            return originName;
        }

        public void setOriginName(String originName) {
            this.originName = originName;
        }

        public String getLowerCamelName() {
            return lowerCamelName;
        }

        public void setLowerCamelName(String lowerCamelName) {
            this.lowerCamelName = lowerCamelName;
        }

        public String getUpperCamelName() {
            return upperCamelName;
        }

        public void setUpperCamelName(String upperCamelName) {
            this.upperCamelName = upperCamelName;
        }

        public String getJdbcType() {
            return jdbcType;
        }

        public void setJdbcType(String jdbcType) {
            this.jdbcType = jdbcType;
        }

        public String getJavaType() {
            return javaType;
        }

        public void setJavaType(String javaType) {
            this.javaType = javaType;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public void initColumnName(String columnName){
            this.originName = columnName;
            this.lowerCamelName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, columnName);
            this.upperCamelName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, columnName);
        }
    }



    public void initClassName(String tableName){
        this.tableName = tableName;
        this.className = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL,tableName);
        this.lowerClassName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,tableName);
    }

    public void initPkName(String pkName){
        this.pkName = pkName;
        this.upperPkName = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,pkName);
    }


}
